import time

def write_log(username):
    with open('logs.txt', 'a', encoding='utf-8') as f:
        s=f'用户名{username},登录时间：{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}\n'
        f.write(s)

def read_log():
    with open('logs.txt', 'r', encoding='utf-8') as f:
        while True:
            line = f.readline()
            if line == '':
               break
            else:
                print(line)

if __name__ == '__main__':
    username = input('input username:')
    pwd = input('input password:')

    if username =='admin' and pwd == 'admin':
        write_log(username)
        read_log()

